go to previous page   go to home page   go to next page

Answer:

Yes. Place the two button panels in a top panel. Use horizontal layout for its content pane. Then add the top panel and the result panel to the frame.


Class Box

Layout managers sometimes jam components together in a way that makes the layout look cramped. The class Box can help in this situation. A Box object is a container similar to a panel, but lacking some features. The default layout manager of Box is BoxLayout. Several previous example programs could be rewritten using Box in place of JPanel. This would slightly simplify the code since it would rely on the default BoxLayout manager rather than specifically setting it. Constructors for Box look like this:

public Box(int axis)

    -- axis is one of: BoxLayout.X_AXIS, BoxLayout.Y_AXIS, (and a few others)

Class Box has methods that create invisible components corresponding to rectangular areas of the screen. These are used as spacers to separate the visible components. To create a fixed-sized invisible component use the method:

Box.createRigidArea( new Dimension( int width, int height ) )

The parameter is a Dimension object, which does little more than hold a width and a height.


QUESTION 9:

(Thought Question:) Could width and height be arithmetic expressions?